import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import { departmentTreeList } from '@/api/sys/msUser';
import { ywGroupSelectList } from '@/api/heng/ywManage';

import { useUserStore } from '@/store/modules/user';
const userStore = useUserStore();

//表格列名
export const columns: BasicColumn[] = [
  {
    title: '接单人',
    dataIndex: 'receiverUserName',
  },
  {
    title: '接单人比例',
    dataIndex: 'receiverUserRate',
    format: (value: number) => `${value ? value + '%' : ''}`,
    width: 150,
  },
  {
    title: '跟单人',
    dataIndex: 'merchandiserUserName',
  },
  {
    title: '跟单人比例',
    dataIndex: 'merchandiserUserRate',
    format: (value: number) => `${value ? value + '%' : ''}`,
    width: 150,
  },
  {
    title: '类型',
    dataIndex: 'type',
    format: (value: number) => {
       let v="";
       if(value==0){
         v="默认比例设置";
       }else if(value==1){
         v="指定情况设置";

       }
      return v;
    },

    width: 150,
  },
  {
    title: '优先级',
    dataIndex: 'sort',
    width: 80,
  },
  {
    title: '客户编号',
    dataIndex: 'customerNo',
    width: 100,
  },
  {
    title: '部门名称',
    dataIndex: 'deptName',
    width: 100,
  },
  {
    title: '创建时间',
    width: 180,
    dataIndex: 'createTime',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '搜索',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'receiverUserNo',
    label: '接单人NO',
    show: false,
  },
  {
    field: 'receiverUserName',
    label: '接单人',
    required: true,
    slot: 'receiverUserName',
    helpMessage: '当"业务抽成待确认"的接单人与此次的接单人相同时，优先按照此次的比例进行计算!',
  },
  {
    field: 'receiverUserRate',
    label: '接单人抽成比例',
    required: true,
    component: 'InputNumber',
    suffix: '%',
    helpMessage: '接单+跟单 比例不能超过100%',
  },
  {
    field: 'merchandiserUserNo',
    label: '跟单人NO',
    show: false,
  },
  {
    field: 'merchandiserUserName',
    label: '跟单人',
    slot: 'merchandiserUserName',
  },
  {
    field: 'merchandiserUserRate',
    label: '跟单人抽成比例',
    component: 'InputNumber',
    suffix: '%',
    helpMessage: '接单+跟单 比例不能超过100%',
  },
  {
    field: 'type',
    label: '类型',
    component: 'Select',
    componentProps:{
      options:[
        { label: '默认比例设置', value: 0 },
        { label: '指定情况设置', value: 1 },
      ]
    }
  },
  {
    field: 'sort',
    label: '优先级',
    component: 'InputNumber',
  },
  {
    field: 'customerNo',
    label: '客户编号',
    component: 'Input',
  },
  {
    field: 'deptName',
    label: '部门名称',
    component: 'Input',
  },
];
